const path = require("path");
const Htmlwebpackplugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const { HotModuleReplacementPlugin } = require("webpack");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const webpack = require('webpack')

module.exports = {
    mode: 'none',
    entry: path.join(__dirname, 'src/main.js'), // 入口文件
    output: {
        filename: "bundle.js",
        path: path.resolve(__dirname, "dist")
    },
    module: {
        rules: [
            // {
            //     test: /\.css$/,
            //     use: [
            //         // "style-loader",
            //         MiniCssExtractPlugin.loader,
            //         "css-loader",
            //         'postcss-loader'
            //     ]
            // },
            {
                test: /\.less$/,
                use: [
                    // "style-loader",
                    MiniCssExtractPlugin.loader,
                    "css-loader",
                    // 'postcss-loader',
                    "less-loader"
                ]
            },
            {
                test: /\.(html|htm)$/,
                use: ["html-loader"]
            },
            {
                test: /\.(png|jpg|svg|webp|jpeg)$/,
                use: {
                    loader: "url-loader",
                    options: {
                        esModule: false,
                        limit: 50 * 1024,
                        name: "[hash:10].[ext]"
                    }
                }
            },
            {
                exclude: /\.(html|js|png|jpg|css|less|gif)/,
                loader: "file-loader",
                options: {
                  name: "[hash:10].[ext]"
                }
              }
        ]
    },
    devServer: {
        contentBase: 'public', //静态资源访问
    },
    plugins: [
        new CleanWebpackPlugin(),
        new HotModuleReplacementPlugin()
    ]
}